package com.lucenly.card.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lucenly.card.R;
import com.lucenly.card.bean.ProblemBean;

public class ProblemAdapter extends BaseQuickAdapter<ProblemBean,BaseViewHolder>{

    public ProblemAdapter(){
        super(R.layout.item_problem);
    }
    @Override
    protected void convert(BaseViewHolder helper, ProblemBean item) {
        TextView tv_name = helper.getView(R.id.tv_name);
        final TextView tv_detail = helper.getView(R.id.tv_detail);
        LinearLayout ll_item = helper.getView(R.id.ll_item);
        final ImageView image = helper.getView(R.id.iv_go);
        ll_item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(tv_detail.getVisibility()==View.GONE){
                    image.setPivotX(image.getWidth()/2);
                    image.setPivotY(image.getHeight()/2);//支点在图片中心
                    image.setRotation(90);
                    tv_detail.setVisibility(View.VISIBLE);
                }else{
                    image.setPivotX(image.getWidth()/2);
                    image.setPivotY(image.getHeight()/2);//支点在图片中心
                    image.setRotation(0);
                    tv_detail.setVisibility(View.GONE);

                }
            }
        });
        tv_name.setText(helper.getAdapterPosition()+1+"."+item.getTitle());
        tv_detail.setText(item.getContent());

    }
}
